namespace Ds.DataBase.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class updateMoBan : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.JiXiaoSons", "JiXiao_mbid", "dbo.JiXiaos");
            DropIndex("dbo.JiXiaoSons", new[] { "JiXiao_mbid" });
            CreateTable(
                "dbo.GongZuoJiHuaNeiRongs",
                c => new
                    {
                        gzjhnrid = c.Int(nullable: false, identity: true),
                        gzjhsx = c.Int(nullable: false),
                        gzjhnr = c.String(),
                        gzjhfz = c.Decimal(nullable: false, precision: 18, scale: 2),
                        gzjhhtml = c.String(),
                        GongZuoJiHua_mbid = c.Int(),
                    })
                .PrimaryKey(t => t.gzjhnrid)
                .ForeignKey("dbo.GongZuoJiHuas", t => t.GongZuoJiHua_mbid)
                .Index(t => t.GongZuoJiHua_mbid);
            
            CreateTable(
                "dbo.JiXiaoNeiRongs",
                c => new
                    {
                        jxnrid = c.Int(nullable: false, identity: true),
                        jxsx = c.Int(nullable: false),
                        jxnr = c.String(),
                        jxfz = c.Decimal(nullable: false, precision: 18, scale: 2),
                        jxhtml = c.String(),
                        JiXiao_mbid = c.Int(),
                    })
                .PrimaryKey(t => t.jxnrid)
                .ForeignKey("dbo.JiXiaos", t => t.JiXiao_mbid)
                .Index(t => t.JiXiao_mbid);
            
            AddColumn("dbo.JiXiaoSons", "JiXiaoNeiRong_jxnrid", c => c.Int());
            CreateIndex("dbo.JiXiaoSons", "JiXiaoNeiRong_jxnrid");
            AddForeignKey("dbo.JiXiaoSons", "JiXiaoNeiRong_jxnrid", "dbo.JiXiaoNeiRongs", "jxnrid");
            DropColumn("dbo.GongZuoJiHuas", "jhsx");
            DropColumn("dbo.GongZuoJiHuas", "gzjhnr");
            DropColumn("dbo.GongZuoJiHuas", "gzjhfz");
            DropColumn("dbo.GongZuoJiHuas", "gzjhhtml");
            DropColumn("dbo.JiXiaos", "jxsx");
            DropColumn("dbo.JiXiaos", "jxnr");
            DropColumn("dbo.JiXiaos", "jxfz");
            DropColumn("dbo.JiXiaos", "jxhtml");
            DropColumn("dbo.JiXiaoSons", "JiXiao_mbid");
        }
        
        public override void Down()
        {
            AddColumn("dbo.JiXiaoSons", "JiXiao_mbid", c => c.Int());
            AddColumn("dbo.JiXiaos", "jxhtml", c => c.String());
            AddColumn("dbo.JiXiaos", "jxfz", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            AddColumn("dbo.JiXiaos", "jxnr", c => c.String());
            AddColumn("dbo.JiXiaos", "jxsx", c => c.Int(nullable: false));
            AddColumn("dbo.GongZuoJiHuas", "gzjhhtml", c => c.String());
            AddColumn("dbo.GongZuoJiHuas", "gzjhfz", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            AddColumn("dbo.GongZuoJiHuas", "gzjhnr", c => c.String());
            AddColumn("dbo.GongZuoJiHuas", "jhsx", c => c.Int(nullable: false));
            DropForeignKey("dbo.JiXiaoNeiRongs", "JiXiao_mbid", "dbo.JiXiaos");
            DropForeignKey("dbo.JiXiaoSons", "JiXiaoNeiRong_jxnrid", "dbo.JiXiaoNeiRongs");
            DropForeignKey("dbo.GongZuoJiHuaNeiRongs", "GongZuoJiHua_mbid", "dbo.GongZuoJiHuas");
            DropIndex("dbo.JiXiaoSons", new[] { "JiXiaoNeiRong_jxnrid" });
            DropIndex("dbo.JiXiaoNeiRongs", new[] { "JiXiao_mbid" });
            DropIndex("dbo.GongZuoJiHuaNeiRongs", new[] { "GongZuoJiHua_mbid" });
            DropColumn("dbo.JiXiaoSons", "JiXiaoNeiRong_jxnrid");
            DropTable("dbo.JiXiaoNeiRongs");
            DropTable("dbo.GongZuoJiHuaNeiRongs");
            CreateIndex("dbo.JiXiaoSons", "JiXiao_mbid");
            AddForeignKey("dbo.JiXiaoSons", "JiXiao_mbid", "dbo.JiXiaos", "mbid");
        }
    }
}
